﻿using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Dto.Output.EliminationmodelsOutput;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;
using IntelligentAgriculture.Contracts.Interface.EliminationModelService;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EliminationModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.EliminationModelCommandHandler
{
    public class EliminationShowCommandHandler : IRequestHandler<EliminationShowCommand, Results<PagesOutput<EliminationmodelShowOutput>>>
    {
        private readonly IEliminationModelService _IeliminationModelService;
        public EliminationShowCommandHandler(IEliminationModelService ieliminationModelService)
        {
            _IeliminationModelService = ieliminationModelService;
        }
        /// <summary>
        /// 淘汰显示，查询，分页
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<PagesOutput<EliminationmodelShowOutput>>> Handle(EliminationShowCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _IeliminationModelService.GetShow(request.Eitag);
                var results = Results<PagesOutput<EliminationmodelShowOutput>>.DataResult(list);
                return results;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
